import { SHOPEE_FONT } from '@/pages/TemplateEditor/components/Editor/components/TemplateEffect/constant';
import styles from '../RichTextAddon/index.module.less';

export const getClassActive = (key, value, data): string =>
  data[key] === value ? styles.active : '';

export const getFontClassActive = (key, value, data): string =>
  data[key].includes(value) ? styles.active : '';

export const getFontFamily = (families: string): string => {
  if (families.includes(SHOPEE_FONT)) {
    return SHOPEE_FONT;
  }

  const family = families.split(',');
  const defaultFontFamily = family[family.length - 1];
  return defaultFontFamily;
};

export const getShopeeFontFamily = (families: string): string => {
  const family = families.split(',')[0].split('-');
  const defaultFontFamily = family[1];
  return defaultFontFamily;
};
